home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / jpsrc2.zip / JCONFIG.H < prev    next >
C/C++ Source or Header  |  1991-12-09  |  11KB  |  335 lines

  1. /*
  2.  * jconfig.h
  3.  *
  4.  * Copyright (C) 1991, Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This file contains preprocessor declarations that help customize
  9.  * the JPEG software for a particular application, machine, or compiler.
  10.  * Edit these declarations as needed (or add -D flags to the Makefile).
  11.  */
  12.  
  13.  
  14. /*
  15.  * These symbols indicate the properties of your machine or compiler.
  16.  * The conditional definitions given may do the right thing already,
  17.  * but you'd best look them over closely, especially if your compiler
  18.  * does not handle full ANSI C.  An ANSI-compliant C compiler should
  19.  * provide all the necessary features; __STDC__ is supposed to be
  20.  * predefined by such compilers.
  21.  */
  22.  
  23. /* Does your compiler support function prototypes? */
  24. /* (If not, you also need to use ansi2knr, see SETUP) */
  25.  
  26. #ifdef __STDC__            /* ANSI C compilers always have prototypes */
  27. #define PROTO
  28. #else
  29. #ifdef __cplusplus        /* So do C++ compilers */
  30. #define PROTO
  31. #endif
  32. #endif
  33.  
  34. /* Does your compiler support the declaration "unsigned char" ? */
  35. /* How about "unsigned short" ? */
  36.  
  37. #ifdef __STDC__            /* ANSI C compilers must support both */
  38. #define HAVE_UNSIGNED_CHAR
  39. #define HAVE_UNSIGNED_SHORT
  40. #endif
  41.  
  42. /* Define this if an ordinary "char" type is unsigned.
  43.  * If you're not sure, leaving it undefined will work at some cost in speed.
  44.  * If you defined HAVE_UNSIGNED_CHAR then it doesn't matter very much.
  45.  */
  46.  
  47. /* #define CHAR_IS_UNSIGNED */
  48.  
  49. /* Define this if your compiler implements ">>" on signed values as a logical
  50.  * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift,
  51.  * which is the normal and rational definition.
  52.  * The DCT and IDCT routines will compute wrong values if you get this wrong!
  53.  */
  54.  
  55. /* #define RIGHT_SHIFT_IS_UNSIGNED */
  56.  
  57. /* Define "void" as "char" if your compiler doesn't know about type void.
  58.  * NOTE: be sure to define void such that "void *" represents the most general
  59.  * pointer type, e.g., that returned by malloc().
  60.  */
  61.  
  62. /* #define void char */
  63.  
  64. /* Define const as empty if your compiler doesn't know the "const" keyword. */
  65. /* (Even if it does, defining const as empty won't break anything.) */
  66.  
  67. #ifndef __STDC__        /* ANSI C and C++ compilers should know it. */
  68. #ifndef __cplusplus
  69. #define const
  70. #endif
  71. #endif
  72.  
  73. /* For 80x86 machines, you need to define NEED_FAR_POINTERS,
  74.  * unless you are using a large-data memory model or 80386 flat-memory mode.
  75.  * On less brain-damaged CPUs this symbol must not be defined.
  76.  * (Defining this symbol causes large data structures to be referenced through
  77.  * "far" pointers and to be allocated with a special version of malloc.)
  78.  */
  79.  
  80. #ifdef MSDOS            /* Microsoft C and compatibles */
  81. #define NEED_FAR_POINTERS
  82. #else
  83. #ifdef __TURBOC__        /* Turbo C doesn't define MSDOS */
  84. #define NEED_FAR_POINTERS
  85. #endif
  86. #endif
  87.  
  88.  
  89. /* The next couple of symbols only affect the system-dependent user interface
  90.  * modules (jcmain.c, jdmain.c).  You can ignore these if you are supplying
  91.  * your own user interface code.
  92.  */
  93.  
  94. /* Define this if you want to name both input and output files on the command
  95.  * line, rather than using stdout and optionally stdin.  You MUST do this if
  96.  * your system can't cope with binary I/O to stdin/stdout.  See comments at
  97.  * head of jcmain.c or jdmain.c.
  98.  */
  99.  
  100. #ifdef MSDOS            /* two-file style is needed for PCs */
  101. #define TWO_FILE_COMMANDLINE
  102. #else
  103. #ifdef __TURBOC__        /* Turbo C doesn't define MSDOS */
  104. #define TWO_FILE_COMMANDLINE
  105. #endif
  106. #endif
  107. #ifdef THINK_C            /* needed for Macintosh too */
  108. #define TWO_FILE_COMMANDLINE
  109. #endif
  110.  
  111. /* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
  112.  * This is necessary on systems that distinguish text files from binary files,
  113.  * and is harmless on most systems that don't.  If you have one of the rare
  114.  * systems that complains about the "b" spec, define this symbol.
  115.  */
  116.  
  117. /* #define DONT_USE_B_MODE */
  118.  
  119.  
  120. /* If you're getting bored, that's the end of the symbols you HAVE to
  121.  * worry about.  Go fix the makefile and compile.
  122.  */
  123.  
  124.  
  125. /* If your compiler supports inline functions, define INLINE as
  126.  * the inline keyword; otherwise define it as empty.
  127.  */
  128.  
  129. #ifdef __GNUC__            /* GNU C has inline... */
  130. #define INLINE inline
  131. #else                /* ...but I don't think anyone else does. */
  132. #define INLINE
  133. #endif
  134.  
  135. /* On a few systems, type boolean and/or macros FALSE, TRUE may appear
  136.  * in standard header files.  Or you may have conflicts with application-
  137.  * specific header files that you want to include together with these files.
  138.  * In that case you need only comment out these definitions.
  139.  */
  140.  
  141. typedef int boolean;
  142. #undef FALSE            /* in case these macros already exist */
  143. #undef TRUE
  144. #define FALSE    0        /* values of boolean */
  145. #define TRUE    1
  146.  
  147. /* This defines the size of the I/O buffers for entropy compression
  148.  * and decompression; you could reduce it if memory is tight.
  149.  */
  150.  
  151. #define JPEG_BUF_SIZE    4096 /* bytes */
  152.  
  153.  
  154.  
  155. /* These symbols determine the JPEG functionality supported. */
  156.  
  157. /*
  158.  * These defines indicate whether to include various optional functions.
  159.  * Undefining some of these symbols will produce a smaller but less capable
  160.  * program file.  Note that you can leave certain source files out of the
  161.  * compilation/linking process if you've #undef'd the corresponding symbols.
  162.  * (You may HAVE to do that if your compiler doesn't like null source files.)
  163.  */
  164.  
  165. /* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */
  166. #undef  ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  167. #define MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  168. #define ENTROPY_OPT_SUPPORTED    /* Optimization of entropy coding parms? */
  169. #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing during decoding? */
  170. #define QUANT_1PASS_SUPPORTED    /* 1-pass color quantization? */
  171. #undef  QUANT_2PASS_SUPPORTED    /* 2-pass color quantization? (not yet impl.) */
  172. /* these defines indicate which JPEG file formats are allowed */
  173. #define JFIF_SUPPORTED        /* JFIF or "raw JPEG" files */
  174. #undef  JTIFF_SUPPORTED        /* JPEG-in-TIFF (not yet implemented) */
  175. /* these defines indicate which image (non-JPEG) file formats are allowed */
  176. #define GIF_SUPPORTED        /* GIF image file format */
  177. /* #define RLE_SUPPORTED */    /* RLE image file format */
  178. #define PPM_SUPPORTED        /* PPM/PGM image file format */
  179. #define TARGA_SUPPORTED        /* Targa image file format */
  180. #undef  TIFF_SUPPORTED        /* TIFF image file format (not yet impl.) */
  181.  
  182. /* more capability options later, no doubt */
  183.  
  184.  
  185. /*
  186.  * Define exactly one of these three symbols to indicate whether you want
  187.  * 8-bit, 12-bit, or 16-bit sample (pixel component) values.  8-bit is the
  188.  * default and is nearly always the right thing to use.  You can use 12-bit if
  189.  * you need to support image formats with more than 8 bits of resolution in a
  190.  * color value.  16-bit should only be used for the lossless JPEG mode (not
  191.  * currently supported).  Note that 12- and 16-bit values take up twice as
  192.  * much memory as 8-bit!
  193.  */
  194.  
  195. #define EIGHT_BIT_SAMPLES
  196. #undef  TWELVE_BIT_SAMPLES
  197. #undef  SIXTEEN_BIT_SAMPLES
  198.  
  199.  
  200.  
  201. /*
  202.  * The remaining definitions don't need to be hand-edited in most cases.
  203.  * You may need to change these if you have a machine with unusual data
  204.  * types; for example, "char" not 8 bits, "short" not 16 bits,
  205.  * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,
  206.  * but it had better be at least 16.
  207.  */
  208.  
  209. /* First define the representation of a single pixel element value. */
  210.  
  211. #ifdef EIGHT_BIT_SAMPLES
  212. #define BITS_IN_JSAMPLE  8
  213.  
  214. /* JSAMPLE should be the smallest type that will hold the values 0..255.
  215.  * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
  216.  * If you have only signed chars, and you are more worried about speed than
  217.  * memory usage, it might be a win to make JSAMPLE be short.
  218.  */
  219.  
  220. #ifdef HAVE_UNSIGNED_CHAR
  221.  
  222. typedef unsigned char JSAMPLE;
  223. #define GETJSAMPLE(value)  (value)
  224.  
  225. #else /* not HAVE_UNSIGNED_CHAR */
  226. #ifdef CHAR_IS_UNSIGNED
  227.  
  228. typedef char JSAMPLE;
  229. #define GETJSAMPLE(value)  (value)
  230.  
  231. #else /* not CHAR_IS_UNSIGNED */
  232.  
  233. typedef char JSAMPLE;
  234. #define GETJSAMPLE(value)  ((value) & 0xFF)
  235.  
  236. #endif /* CHAR_IS_UNSIGNED */
  237. #endif /* HAVE_UNSIGNED_CHAR */
  238.  
  239. #define MAXJSAMPLE    255
  240. #define CENTERJSAMPLE    128
  241.  
  242. #endif /* EIGHT_BIT_SAMPLES */
  243.  
  244.  
  245. #ifdef TWELVE_BIT_SAMPLES
  246. #define BITS_IN_JSAMPLE  12
  247.  
  248. /* JSAMPLE should be the smallest type that will hold the values 0..4095. */
  249. /* On nearly all machines "short" will do nicely. */
  250.  
  251. typedef short JSAMPLE;
  252. #define GETJSAMPLE(value)  (value)
  253.  
  254. #define MAXJSAMPLE    4095
  255. #define CENTERJSAMPLE    2048
  256.  
  257. #endif /* TWELVE_BIT_SAMPLES */
  258.  
  259.  
  260. #ifdef SIXTEEN_BIT_SAMPLES
  261. #define BITS_IN_JSAMPLE  16
  262.  
  263. /* JSAMPLE should be the smallest type that will hold the values 0..65535. */
  264.  
  265. #ifdef HAVE_UNSIGNED_SHORT
  266.  
  267. typedef unsigned short JSAMPLE;
  268. #define GETJSAMPLE(value)  (value)
  269.  
  270. #else /* not HAVE_UNSIGNED_SHORT */
  271.  
  272. /* If int is 32 bits this'll be horrendously inefficient storage-wise.
  273.  * But since we don't actually support 16-bit samples (ie lossless coding) yet,
  274.  * I'm not going to worry about making a smarter definition ...
  275.  */
  276. typedef unsigned int JSAMPLE;
  277. #define GETJSAMPLE(value)  (value)
  278.  
  279. #endif /* HAVE_UNSIGNED_SHORT */
  280.  
  281. #define MAXJSAMPLE    65535
  282. #define CENTERJSAMPLE    32768
  283.  
  284. #endif /* SIXTEEN_BIT_SAMPLES */
  285.  
  286.  
  287. /* Here we define the representation of a DCT frequency coefficient.
  288.  * This should be a signed 16-bit value; "short" is usually right.
  289.  * It's important that this be exactly 16 bits, no more and no less;
  290.  * more will cost you a BIG hit of memory, less will give wrong answers.
  291.  */
  292.  
  293. typedef short JCOEF;
  294.  
  295.  
  296. /* The remaining typedefs are used for various table entries and so forth.
  297.  * They must be at least as wide as specified; but making them too big
  298.  * won't cost a huge amount of memory, so we don't provide special
  299.  * extraction code like we did for JSAMPLE.  (In other words, these
  300.  * typedefs live at a different point on the speed/space tradeoff curve.)
  301.  */
  302.  
  303. /* UINT8 must hold at least the values 0..255. */
  304.  
  305. #ifdef HAVE_UNSIGNED_CHAR
  306. typedef unsigned char UINT8;
  307. #else /* not HAVE_UNSIGNED_CHAR */
  308. #ifdef CHAR_IS_UNSIGNED
  309. typedef char UINT8;
  310. #else /* not CHAR_IS_UNSIGNED */
  311. typedef short UINT8;
  312. #endif /* CHAR_IS_UNSIGNED */
  313. #endif /* HAVE_UNSIGNED_CHAR */
  314.  
  315. /* UINT16 must hold at least the values 0..65535. */
  316.  
  317. #ifdef HAVE_UNSIGNED_SHORT
  318. typedef unsigned short UINT16;
  319. #else /* not HAVE_UNSIGNED_SHORT */
  320. typedef unsigned int UINT16;
  321. #endif /* HAVE_UNSIGNED_SHORT */
  322.  
  323. /* INT16 must hold at least the values -32768..32767. */
  324.  
  325. #ifndef XMD_H            /* X11/xmd.h correctly defines INT16 */
  326. typedef short INT16;
  327. #endif
  328.  
  329. /* INT32 must hold signed 32-bit values; if your machine happens */
  330. /* to have 64-bit longs, you might want to change this. */
  331.  
  332. #ifndef XMD_H            /* X11/xmd.h correctly defines INT32 */
  333. typedef long INT32;
  334. #endif
  335.